
<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="UTF-8">
        <title>登录</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        {#<link rel="icon" type="image/png" href="/public/images/favicon.png">#}
        <link href="/statics/webadmin/login/css/bootstrap.min.css"  rel="stylesheet" media="screen">
        <link href="/statics/webadmin/login/css/login_base.css" rel="stylesheet">
        <link href="/statics/webadmin/login/css/reg_login.css" rel="stylesheet">
        <link href="/statics/webadmin/login/css/base.css" rel="stylesheet">
        <script src="/statics/webadmin/login/js/jquery-1.10.2.min.js"></script>

    </head>
	<body id="login">

		<div class="container">
            <div class="row">
				<div class="col-lg-4 col-lg-offset-4">
					<a class="reg-logo" href="/"></a>
				</div>
			</div>
			<div class="row">
				<div class="col-lg-6 col-lg-offset-3">

					<div style="margin-top:10px;">
					    <div id="system-message-username" class="system-message-error" style="display:none"></div>
                        <div id="system-message-pwd" class="system-message-error" style="display:none"></div>
                        <div id="system-message-verifyCode" class="system-message-error" style="display:none"></div>
                    </div>
				</div>
			</div>


			<div class="row">
			<div class="col-lg-6 col-lg-offset-3">
				<div class="panel panel-default" style="border: 1px solid #ddd;">

                    <div class="panel-heading">
					  	<div class="container-fluid">
					  		<div class="row">
					  			<div class="col-lg-12">
					  				<h3>登录</h3>
					  			</div>
					  		</div>
					  	</div>
					  </div>
                    <div class="panel-body">
                        <form class="form-reg" id="form" role="form" method="post">
                            {% csrf_token %}
                            <div class="container-fluid">
                                <div class="row">
									<div class="col-lg-12">
									  <div class="form-group">
									  <input class="form-control" placeholder="请输入用户名" name="name" id="name" type="text" />									  </div>
									</div>
								</div>
							</div>
                            <div class="container-fluid">
                                <div class="row">
									<div class="col-lg-12">
									  <div class="form-group">
									  <input class="form-control" placeholder="请输入密码" name="password" id="password" type="password" />									  </div>
									</div>
								</div>
							</div>

                            <div class="panel-footer">
                                <div class="container-fluid">
                                    <div class="row">
                                        <div class="col-lg-10">
                                            <input class="btn btn-success btn-lg btn-login pull-right" type="button" onclick="Submit();" value="登录">
                                        </div>
                                    </div>
                                </div>
                            </div>
						</form>
					  </div>


			</div>

			</div>
			</div>

		</div>

        <script>

            
            function Submit() {
                $("#form").find('p[class="error-p"]').remove();

                var csrfmiddlewaretoken = $("body input[name='csrfmiddlewaretoken']").val();
                var post_data = $("#form").serialize() + "&csrfmiddlewaretoken=" + csrfmiddlewaretoken;

                $.post("{% url 'login' %}", post_data, function(data){

                        if (!data['status']){ // 条件成立的时候则表示有错误信息
                            for (var key in data['error']){
                                var p_tag = document.createElement('p');
                                p_tag.setAttribute('class', 'error-p');
                                p_tag.innerHTML = data['error'][key];
                                $("#form input[name="+key+"]").after(p_tag);

                            }
                        }else{
                            location.href = "{% url 'admin_index' %}";
                        }

                    }, "json");
            }
        </script>
    </body>
</html>